package com.fouram.web.base;

import com.fouram.core.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 控制器基类
 * 
 * @author Liup
 */
public abstract class BaseController {

	@Autowired
	protected TokenService tokenService;

	public HttpServletRequest getRequest() {
		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
				.getRequest();
		return request;
	}
	
	public String getRootPath() {
		return getRequest().getServletContext().getRealPath("/");
	}

	protected Long getLoginId(){
		return tokenService.getLoginId();
	}
}
